package com.webserver.core;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * @author liyang
 * @version 1.0
 * @package com.webserver.core
 * @file BirdBootApplication.java
 * @description
 * @time 2024-04-30 11:02
 */
public class BirdBootApplication {
    /*一*/
    private ServerSocket serverSocket;
    /*二*/
    public BirdBootApplication(){
        try {
            System.out.println("正在启动服务端...");
            serverSocket = new ServerSocket(8088);
            System.out.println("服务端启动完毕！");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    /*三*/
    public void start(){
        try {

            System.out.println("等待客户端连接...");
            Socket socket = serverSocket.accept();
            System.out.println("客户端连接了...");
            /*把server中的ClientHandler另起一类*/
            /*启动线程*/
            ClientHandler handler = new ClientHandler(socket);
            Thread t = new Thread(handler);
            t.start();

        } catch (IOException e) {
            e.printStackTrace();
        }

    }
    /*四*/
    public static void main(String[] args) {
        BirdBootApplication application = new BirdBootApplication();
        application.start();

    }
}
